<template>
  <div>
    <tabbar></tabbar>

    <div class="content">
      <div class="yifu">
        <p class="tit">环保公益-旧衣物捐赠</p>
        <p>环保公益不是我们做了多少，而是所有人都做一点点</p>
      </div>
      <div class="card" v-if="cardData">
        <ul>
          <li>
            <div class="tit" :class="cardShow?'activeTit':''" @click="tit1">
              {{cardData[0].tit}}
              <p v-show="cardShow">▲</p>
            </div>
            <div class="cardItem" v-show="cardShow">
              <div class="smallTitle">
                {{cardData[0].stitle}}
                <p>{{cardData[0].stitlep}}</p>
              </div>

              <div class="itemRight">
                <div class="txtBox">
                  <h3>{{cardData[0].txtTit}}</h3>
                  <p>{{cardData[0].txtp}}</p>
                </div>
                <div class="imgs">
                  <div class="imgBox" v-for="item in cardData[0].image" :key="item.id">
                    <img :src="item.img" alt="">
                  </div>
                </div>
              </div>

            </div>
          </li>

          <li>
            <div class="tit" :class="cardShow?'':'activeTit'" @click="tit2">
              {{cardData[1].tit}}
              <p v-show="!cardShow">▲</p>
            </div>
            <div class="cardItem cardItem2" v-show="!cardShow">
              <div class="smallTitle">
                {{cardData[1].stitle}}
                <p>{{cardData[1].stitlep}}</p>
              </div>

              <div class="itemRight">
                <div class="txtBox">
                  <h3>{{cardData[1].txtTit}}</h3>
                  <p>{{cardData[1].txtp}}</p>
                </div>
                <div class="imgs">
                  <div class="imgBox" v-for="item in cardData[1].image" :key="item.id">
                    <img :src="item.img" alt="">
                  </div>
                </div>
              </div>
            </div>
          </li>
        </ul>
      </div>
      <List :listData='listData'></List>
      <div class="startGoods" @click="needGoods">
        <van-button style="color:#716457;border:2px solid #716457;border-radius:5px" size="large">需要帮助</van-button>
      </div>
    </div>

    <end></end>
  </div>
</template>
<script>
 
import List from '@/views/Goods/List'
import Vue from 'vue';
import { Button } from 'vant';
Vue.use(Button);
import {getGoods} from '@/api/Goods'

export default {
  data () {
    return {
      cardShow: true,
      cardData: '',
      listData:{}
    }
  },
  methods: {
    tit1 () {
      this.cardShow = true
    },
    tit2 () {
      this.cardShow = false
    },
    needGoods () {
      this.$router.push('/needgoods')
    }
  },
  components: {
    List
  },
  mounted () {
    getGoods().then(res => {
      // console.log(res.data);
      this.cardData = res.data.cardData
      this.listData = res.data.list
    })
  }
}
</script>
<style lang="scss" scoped>
.content {
  width: 1200px;
  margin: auto;

  .yifu {
    width: 100%;
    margin-top: 40px;
    background: hsl(19, 100%, 58%);
    padding-top: 20px;
    .tit {
      text-align: center;
      font-size: 35px;
      color: #ffffff;
    }
    p {
      text-align: center;
      font-size: 16px;
      color: rgb(255, 255, 255);
    }
  }
  .card {
    width: 100%;
    margin-top: 30px;
    ul {
      width: 100%;
      display: flex;
      li {
        width: 50%;
        position: relative;
        height: 400px;
        .tit {
          font-size: 24px;
          text-align: center;
          color: rgb(56, 51, 51);
          padding: 10px 0;
          border-top: 2px solid;
        }
        .activeTit {
          border-top: 2px solid;
          color: #83a90d;
          // margin-top: -2px;
        }
        .cardItem {
          // background: paleturquoise;
          position: absolute;
          width: 1200px;
          display: flex;
          border-top: 1px solid #c0c0c0;
          padding-top: 20px;
          .smallTitle {
            background: rgb(56, 51, 51);
            width: 240px;
            height: 240px;
            text-align: center;
            line-height: 240px;
            font-size: 20px;
            border-radius: 50%;
            margin: auto;
            position: relative;
            color: #fff;
            transition: background 1s;
            p {
              position: absolute;
              top: 30px;
              left: 60px;
              font-size: 14px;
            }
          }
          .smallTitle:hover {
            background: #83a90d;
          }
          .itemRight {
            // border: 1px solid;
            .txtBox {
              width: 800px;
              h3 {
                font-size: 26px;
              }
              p {
                font-size: 16px;
                margin-top: 10px;
                color: #666;
              }
            }
            .imgs {
              display: flex;
              width: 100%;
              justify-content: space-between;
              margin-top: 20px;
              .imgBox {
                overflow: hidden;
                // background: #000;
                width: 380px;
              }
            }
          }
        }
        .cardItem2 {
          left: -600px;
        }
      }
    }
  }
  .startGoods {
    width: 200px;
    margin: 40px auto;
    text-align: center;
  }
}
</style>